-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specifying simple gRPC transport credentials #508
Conversation
This is a preliminary PR to see if you are interested in this, if so I'll fix up the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should differentiate between server certs and client certs. What if that is different? Also you state that in description that those flags are for incoming request and then you use it for store client connections.
Also, what if each storeAPI will required different key?
cmd/thanos/flags.go
Outdated
grpcBindAddr := cmd.Flag("grpc-address", "Listen ip:port address for gRPC endpoints (StoreAPI). Make sure this address is routable from other components if you use gossip, 'grpc-advertise-address' is empty and you require cross-node connection."). | ||
Default("0.0.0.0:10901").String() | ||
|
||
grpcAdvertiseAddr := cmd.Flag("grpc-advertise-address", "Explicit (external) host:port address to advertise for gRPC StoreAPI in gossip cluster. If empty, 'grpc-address' will be used."). | ||
String() | ||
|
||
grpcTLSInsecure := cmd.Flag("grpc-tls-insecure", "Do not use gRPC transport credentials to verify connections").Default("true").Bool() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure in the name to be clear that this touches incoming requests.
Just note that only thanos query calls those grpc Requests. Rest is only serving those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
For the first stab I went for the simplest setup, but TBH this isn't what I'd do for production services (this is how the gRPC examples set things up). Ideally we'd have:
Unfortunately this ends up amounting to an awful lot of cli flags. grpc-server-cert Thoughts? |
fb740ea
to
25678f5
Compare
@Bplotka updated the arg names, they still aren't very pretty. If you have specific ideas, please do say. (personally I'd have something like --query.tls.caCert , --grpc.tls.cert --grpc.tls.key, some of the existing args seem to follow that kind of format, but I've not been able to discern a pattern to them. opted for creds rather than tlsCreds, it's a little more accurate, and matches the functions they are then used with. |
Mostly note to self. Will add client key/cert and server client verification CA. Need this (or actual per roc auth cress) for minimal secure use case |
@Bplotka updated to provide full client cert and server side verification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks really really nice! Some minor issues only. Thanks!
cmd/thanos/query.go
Outdated
*insecure, | ||
*srvcert, | ||
*srvkey, | ||
*srvclientca, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make it camelCase everywhere: srvKey
srvClientCA
etc
b448646
to
0c41c21
Compare
Can we have some rebase? |
@Bplotka opened a whole can of rebase! |
@Bplotka fixed my dep woes, docs and deps updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments. Two more suggestions before merging.
00622b2
to
113a71e
Compare
@bwplotka we're running this locally with seeming success. Have yet to confirm query -> multiple store gateways over a WAN, but single query to single gateway in cluster is fine. |
Let's change the |
@bwplotka rebased on master, not quite sure what is going on with the Gopkg.lock, possible my version of dep is too old/new? |
what do you use for deps? Can you use reset your changes on |
@bwplotka reset it and |
finally some tooling work paid off 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, I added some minor suggestions, but looks really good! Thanks!
cmd/thanos/main.go
Outdated
@@ -227,6 +231,43 @@ func defaultGRPCServerOpts(logger log.Logger, reg *prometheus.Registry, tracer o | |||
grpc_recovery.StreamServerInterceptor(grpc_recovery.WithRecoveryHandler(grpcPanicRecoveryHandler)), | |||
), | |||
} | |||
|
|||
if key == "" || cert == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need error if any of this is filled but not all. Also if clientCA is filled but those keys not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if you want a log and an error, or just an error, and is returning an errors.New OK?
cmd/thanos/query.go
Outdated
creds := credentials.NewTLS(tlsCfg) | ||
dialOpts = append(dialOpts, grpc.WithTransportCredentials(creds)) | ||
|
||
return dialOpts, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, we can just inline this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, sorry for being so strict (: Hope you are not mad... but I think this is the very last suggestion and we are rdy to merge! Approving in advance.
cmd/thanos/main.go
Outdated
level.Info(logger).Log("msg", "gRPC server TLS client verification enabled") | ||
} | ||
|
||
creds := credentials.NewTLS(tlsCfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think you need creds
variable
So our thinking in Thanos is - if you do a variable it means that you need this in more places than just one. Otherwise just inline (: Do you agree with this?
@@ -28,18 +31,24 @@ import ( | |||
"github.com/prometheus/prometheus/promql" | |||
"github.com/prometheus/tsdb/labels" | |||
"google.golang.org/grpc" | |||
"google.golang.org/grpc/credentials" | |||
"gopkg.in/alecthomas/kingpin.v2" | |||
) | |||
|
|||
// registerQuery registers a query command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW what happened to GitHub - coloring for golang sucks ... now there is some red mark on go comments??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or is it only my browser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's doing it for me too, I've no idea what is going on there.
No, review is completely cool, very important to match the project style (it's also a better patch for it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🏷️
Thanks! That is epic addition. |
No description provided.